#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>

int main()
{
    pid_t id = fork();
    if(id == 0)
    {
        //子进程
        int cnt = 5;
        while(cnt)
        {
             printf("我是子进程：%d，父进程：%d，cnt=%d\n",getpid(),getppid(),cnt--);
             sleep(1);
        }
        exit(0);//进程退出
    }
    //父进程
    sleep(7);
    pid_t ret = wait(NULL);
    if(ret > 0)
    {
        printf("wait success: %d\n",ret);
    }
    sleep(2);

    return 0;
}
